| Conditions | 1 |
| Total Lines | 29 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { EMPTY_OBJECT } from "./consts.json" |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Identical function or returning constant `EMPTY_OBJECT` for keys check of not used classes in components tree |
||
| 11 | * @example |
||
| 12 | * ```tsx |
||
| 13 | * // Dummies shape |
||
| 14 | * <Component classnames={classNamesCheck()} />; |
||
| 15 | * ``` |
||
| 16 | * --- |
||
| 17 | * ```tsx |
||
| 18 | * import type { ClassNamesFrom } from "react-classnaming/types" |
||
| 19 | * import css_module from "./some.css" // With class `.never-used {...}` |
||
| 20 | * |
||
| 21 | * <Component classnames={classNamesCheck( |
||
| 22 | * css_module, |
||
| 23 | * //@ts-expect-error Property 'never-used' is missing |
||
| 24 | * {} as ClassNamesFrom<typeof Component> |
||
| 25 | * )} />; |
||
| 26 | * ``` |
||
| 27 | */ |
||
| 28 | function classNamesCheck< |
||
| 29 | Target extends {[K in keyof Module]: ClassHash}, |
||
| 30 | Module extends CssModule |
||
| 31 | >( |
||
| 32 | source = EMPTY_OBJECT as Module, |
||
| 33 | _ = EMPTY_OBJECT as Target |
||
| 34 | ): string extends keyof Module ? Target : Module { |
||
| 35 | //@ts-expect-error |
||
| 36 | return source |
||
| 37 | } |
||
| 38 |